package com.bluefish.bltuan.module.mail;

import static com.bluefish.bltuan.module.mail.EmailVariable.ACTIVE_LINK;
import static com.bluefish.bltuan.module.mail.EmailVariable.NEW_PASSWORD;
import static com.bluefish.bltuan.module.mail.EmailVariable.PASSWORD;
import static com.bluefish.bltuan.module.mail.EmailVariable.SUBSCRIBER_CONTENT;
import static com.bluefish.bltuan.module.mail.EmailVariable.SUBSCRIBER_TITLE;
import static com.bluefish.bltuan.module.mail.EmailVariable.USERNAME;

public enum EmailPurpose {

    REGISTER("register", new EmailVariable[] { USERNAME, PASSWORD, ACTIVE_LINK }),

    FIND_PASSWORD("find-password", new EmailVariable[] { USERNAME, NEW_PASSWORD }),

    SUBSCRIBER("subscribe", new EmailVariable[] { USERNAME, SUBSCRIBER_TITLE, SUBSCRIBER_CONTENT }),

    SUBSCRIBER_NOT_YET("subscriber-not-yet", new EmailVariable[] { USERNAME });

    private String          key;

    private EmailVariable[] variables;

    private EmailPurpose(String key, EmailVariable[] variables) {
        this.key = key;
        this.variables = variables;
    }

    @Override
    public String toString() {
        return this.key;
    }

    public static EmailPurpose valueOfString(String str) {
        String value = str.replaceAll("-", "_").toUpperCase();
        return valueOf(value);
    }

    public String getKey() {
        return key;
    }

    public EmailVariable[] getVariables() {
        return variables;
    }
}
